import {Injectable} from '@angular/core';
import {Subject} from 'rxjs/Subject';
import {Observable} from 'rxjs/Observable';

@Injectable()
export class MessageService {

  private subject = new Subject<any>();

  /*发送一个消息*/
  sendMessage(severity: string, detail: string) {
    this.subject.next({severity: severity, detail: detail});
  }

  /*接受消息*/
  getMessage(): Observable<any> {
    return this.subject.asObservable();
  }
}
